SELECT *
FROM BPS_Patients
WHERE StatusText = 'Active'
AND InternalID IN (
    SELECT i.InternalID
    FROM INVOICES i
    INNER JOIN SERVICES s
    ON i.INVOICEID = s.INVOICEID
    WHERE s.MBSITEM IN (721, 723, 732, 92024, 92025, 92028, 229, 230, 233, 92055, 92056, 92059)
    AND s.SERVICEDATE >= DATEADD(MONTH, -3, GETDATE())
    AND i.RECORDSTATUS = 1
)
ORDER BY surname, firstname;

-- Patients with an GPMP/TCA plan eligible for a GPCCM plan